package mx.groovy;

import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import groovy.lang.Writable;
import groovy.text.Template;
import groovy.text.markup.MarkupTemplateEngine;
import groovy.text.markup.TemplateConfiguration;

public class RenderTest {
	public String createFromTemplate(String tmp, Map modal) throws Exception {
		TemplateConfiguration config = new TemplateConfiguration();         
		MarkupTemplateEngine engine = new MarkupTemplateEngine(config);     
		Template template = engine.createTemplate("p('test template')");    
		Map<String, Object> model = new HashMap<>();          
		Writable output = template.make(model);   
		
		StringWriter writer = new StringWriter();
		output.writeTo(writer);
		return writer.toString();
	}
	
	public  static void main(String args[]) throws Exception {
		RenderTest test = new RenderTest();
		String s = test.createFromTemplate("abc", new HashMap());
		System.out.println(s);
	}
}
